<?php
/**
 * 控制台
**/
include("../includes/common.php");
$title='控制台';
include './head.php';

// 统计数据
$today0 = date("Y-m-d 00:00:00");
$total_files = intval($DB->getColumn("SELECT count(*) FROM pre_file "));
$today_uploads = intval($DB->getColumn("SELECT count(*) FROM pre_file WHERE  addtime>='{$today0}'"));
$total_size = intval($DB->getColumn("SELECT IFNULL(SUM(size),0) FROM pre_file "));
$user_count = intval($DB->getColumn("SELECT count(*) FROM pre_user"));


?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>工作台</title>
    <link rel="stylesheet" href="../assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="../assets/module/admin.css?v=318"/>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            background: #f8fafc;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            color: #1e293b;
            line-height: 1.6;
        }
        
        .admin-dashboard {
            min-height: 100vh;
            padding: 24px;
        }
        
        .hero-section {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 24px;
            padding: 40px;
            margin-bottom: 32px;
            color: white;
            position: relative;
            overflow: hidden;
        }
        
        .hero-section::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: float 8s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px) rotate(0deg); }
            50% { transform: translateY(-20px) rotate(180deg); }
        }
        
        .hero-content {
            position: relative;
            z-index: 2;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 20px;
        }
        
        .hero-text {
            flex: 1;
            min-width: 300px;
        }
        
        .hero-title {
            font-size: 2.5rem;
            font-weight: 800;
            margin-bottom: 12px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .hero-subtitle {
            font-size: 1.1rem;
            opacity: 0.9;
            margin-bottom: 8px;
        }
        
        .hero-quote {
            font-style: italic;
            opacity: 0.8;
            font-size: 0.95rem;
        }
        
        .hero-actions {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
        }
        
        .hero-btn {
            background: rgba(255,255,255,0.15);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255,255,255,0.2);
            color: white;
            padding: 12px 20px;
            border-radius: 12px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .hero-btn:hover {
            background: rgba(255,255,255,0.25);
            transform: translateY(-2px);
            color: white;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 24px;
            margin-bottom: 32px;
        }
        
        .stat-card {
            background: white;
            border-radius: 20px;
            padding: 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
            transition: all 0.3s ease;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        
        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, #667eea, #764ba2);
        }
        
        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.12);
        }
        
        .stat-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .stat-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: #64748b;
        }
        
        .stat-badge {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            padding: 4px 12px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }
        
        .stat-number {
            font-size: 3rem;
            font-weight: 800;
            color: #1e293b;
            margin-bottom: 8px;
            line-height: 1;
        }
        
        .stat-description {
            color: #64748b;
            font-size: 0.95rem;
        }
        
        .content-grid {
            display: grid;
            grid-template-columns: 2fr 1fr;
            gap: 32px;
            margin-bottom: 32px;
        }
        
        .main-content {
            display: flex;
            flex-direction: column;
            gap: 24px;
        }
        
        .chart-card {
            background: white;
            border-radius: 20px;
            padding: 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        }
        
        .chart-title {
            font-size: 1.3rem;
            font-weight: 700;
            color: #1e293b;
            margin-bottom: 24px;
        }
        
        .chart-container {
            height: 300px;
        }
        
        .guide-card {
            background: white;
            border-radius: 20px;
            padding: 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        }
        
        .guide-title {
            font-size: 1.3rem;
            font-weight: 700;
            color: #1e293b;
            margin-bottom: 24px;
        }
        
        .guide-section {
            margin-bottom: 24px;
        }
        
        .guide-section-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: #374151;
            margin-bottom: 12px;
        }
        
        .guide-step {
            background: #f8fafc;
            border-left: 4px solid #667eea;
            padding: 16px 20px;
            border-radius: 8px;
            margin-bottom: 12px;
            font-size: 0.95rem;
            color: #4b5563;
        }
        
        .guide-step a {
            color: #667eea;
            font-weight: 600;
            text-decoration: none;
        }
        
        .guide-step a:hover {
            text-decoration: underline;
        }
        
        .sidebar {
            display: flex;
            flex-direction: column;
            gap: 24px;
        }
        
        .info-card {
            background: white;
            border-radius: 20px;
            padding: 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        }
        
        .info-title {
            font-size: 1.3rem;
            font-weight: 700;
            color: #1e293b;
            margin-bottom: 20px;
        }
        
        .info-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 0;
            border-bottom: 1px solid #f1f5f9;
        }
        
        .info-item:last-child {
            border-bottom: none;
        }
        
        .info-label {
            color: #64748b;
            font-size: 0.95rem;
        }
        
        .info-value {
            color: #1e293b;
            font-weight: 600;
            font-size: 0.95rem;
        }
        
        .info-value a {
            color: #667eea;
            text-decoration: none;
        }
        
        .info-value a:hover {
            text-decoration: underline;
        }
        
        .log-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .log-table th {
            background: #f8fafc;
            padding: 12px;
            text-align: left;
            font-weight: 600;
            color: #374151;
            font-size: 0.9rem;
        }
        
        .log-table td {
            padding: 12px;
            border-bottom: 1px solid #f1f5f9;
            font-size: 0.9rem;
            color: #4b5563;
        }
        
        .log-table tr:last-child td {
            border-bottom: none;
        }
        
        .recommend-card {
            background: white;
            border-radius: 20px;
            padding: 32px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        }
        
        .recommend-item {
            padding: 16px 0;
            border-bottom: 1px solid #f1f5f9;
        }
        
        .recommend-item:last-child {
            border-bottom: none;
        }
        
        .recommend-title {
            font-size: 1rem;
            font-weight: 600;
            color: #667eea;
            margin-bottom: 4px;
        }
        
        .recommend-desc {
            color: #64748b;
            font-size: 0.9rem;
            margin-bottom: 8px;
        }
        
        .recommend-meta {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.85rem;
        }
        
        .recommend-price {
            color: #ef4444;
            font-weight: 600;
        }
        
        .recommend-qq {
            color: #667eea;
            cursor: pointer;
        }
        
        .recommend-time {
            color: #9ca3af;
        }
        
        .loading {
            text-align: center;
            color: #9ca3af;
            padding: 20px;
        }
        
        @media (max-width: 1024px) {
            .content-grid {
                grid-template-columns: 1fr;
            }
            
            .hero-content {
                flex-direction: column;
                align-items: flex-start;
            }
            
            .hero-actions {
                width: 100%;
                justify-content: flex-start;
            }
        }
        
        @media (max-width: 768px) {
            .admin-dashboard {
                padding: 16px;
            }
            
            .hero-section {
                padding: 24px;
            }
            
            .hero-title {
                font-size: 2rem;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
            }
            
            .stat-card {
                padding: 24px;
            }
            
            .stat-number {
                font-size: 2.5rem;
            }
            
            .hero-actions {
                flex-direction: column;
                width: 100%;
            }
            
            .hero-btn {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>
<body>
<div class="admin-dashboard">
    <!-- 欢迎区域 -->
    <div class="hero-section">
        <div class="hero-content">
            <div class="hero-text">
                <h1 class="hero-title">欢迎回来，管理员！</h1>
                <p class="hero-subtitle" id="welcomeTime">正在加载时间...</p>
                <p class="hero-quote" id="hitokoto">加载中...</p>
            </div>
            <div class="hero-actions">
                <a href="userlist.php" class="hero-btn">
                    <i class="layui-icon layui-icon-user"></i>
                    用户管理
                </a>
                <a href="file.php" class="hero-btn">
                    <i class="layui-icon layui-icon-file"></i>
                    文件管理
                </a>
                <a href="set_stor.php" class="hero-btn">
                    <i class="layui-icon layui-icon-set"></i>
                    存储配置
                </a>
                <a href="set.php?mod=file" class="hero-btn">
                    <i class="layui-icon layui-icon-upload"></i>
                    上传配置
                </a>
            </div>
        </div>
    </div>

    <!-- 数据统计卡片 -->
    <div class="stats-grid">
        <div class="stat-card" >
            <div class="stat-header">
                <div class="stat-title">文件总数</div>
            </div>
            <div class="stat-number"><?= $total_files ?></div>
        </div>
        
        <div class="stat-card">
            <div class="stat-header">
                <div class="stat-title">今日上传</div>
            </div>
            <div class="stat-number"><?= $today_uploads ?></div>
        </div>
        
        <div class="stat-card">
            <div class="stat-header">
                 <?php
              function fmtSize($bytes){
                $u=['B','KB','MB','GB','TB']; $i=0; $v=$bytes; while($v>1024 && $i<count($u)-1){ $v/=1024; $i++; }
                return round($v,2).' '.$u[$i];
              }
            ?>
                <div class="stat-title">占用空间</div>
            </div>
            <div class="stat-number"><?= fmtSize($total_size) ?></div>
        </div>
        
        <div class="stat-card" >
            <div class="stat-header">
                <div class="stat-title">用户总数</div>
            </div>
            <div class="stat-number"><?= $user_count ?></div>
        </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="content-grid">
        <div class="main-content">
            <!-- 图表区域 -->
            
            
                         <!-- 使用指南 -->
             <div class="guide-card">
                 <h3 class="guide-title">快速使用指南</h3>
                 <div class="guide-section">
                     <div class="guide-section-title">存储配置</div>
                     <div class="guide-step">
                         1、点击菜单栏的 <a href="set_stor.php">存储配置</a>，先对你使用的平台存储类型的接口进行配置！
                     </div>
                 </div>
                 <div class="guide-section">
                     <div class="guide-section-title">用户组</div>
                     <div class="guide-step">
                         2、点击菜单栏的 <a href="group.php">用户组</a>，然后点击添加《选择你配置的存储类型》获取，然后保存！
                     </div>
                 </div>
             </div>
             
         </div>
         
         <div class="sidebar">
             <!-- 系统信息 -->
             <div class="info-card">
                 <h3 class="info-title">系统信息</h3>
                 <div class="info-item">
                     <span class="info-label">系统名称</span>
                     <span class="info-value">幻影云网盘</span>
                 </div>
                 <div class="info-item">
                     <span class="info-label">系统版本</span>
                     <span class="info-value">1.0</span>
                 </div>
                 <div class="info-item">
                     <span class="info-label">作者</span>
                     <span class="info-value">HuanYing</span>
                 </div>
                 
                 <div class="info-item">
                     <span class="info-label">官方网址</span>
                     <span class="info-value">
                         <a href="//www.52hyjs.com" target="_blank">www.52hyjs.com</a>
                     </span>
                 </div>
                 <div class="info-item">
                     <span class="info-label">官方QQ群</span>
                     <span class="info-value">
                         <a href="https://qm.qq.com/q/ivZfRY7Hea" target="_blank">618311789</a>
                     </span>
                 </div>
                 <div class="info-item">
                     <span class="info-label">温馨提示</span>
                     <span class="info-value" style="font-size: 0.85rem; color: #ef4444;">
                         该程序为免费开源版本！
                     </span>
                 </div>
             </div>
             
             
         </div>
    </div>
</div>

<!-- js部分 -->
<?php include 'foot.php';?>
<script src="../assets/libs/echarts/echarts.min.js"></script>
<script src="../assets/libs/echarts/china.js"></script>
<script src="../assets/libs/echarts/echarts-wordcloud.min.js"></script>
<script type="text/javascript">
    layui.use(['layer', 'table', 'element', 'admin', 'form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var table = layui.table;
        var element = layui.element;
        var admin = layui.admin;
        var form = layui.form;

        // 一言API调用
        function loadHitokoto() {
            $.ajax({
                url: 'https://v1.hitokoto.cn/',
                type: 'GET',
                dataType: 'json',
                success: function(data) {
                    $('#hitokoto').html(data.hitokoto + '<br><small>——' + data.from + '</small>');
                },
                error: function() {
                    $('#hitokoto').html('获取一言失败，请稍后再试');
                }
            });
        }
        loadHitokoto();
        setInterval(loadHitokoto, 60000); // 每分钟更新一次

        // 欢迎时间
        function updateTime() {
            var now = new Date();
            var h = now.getHours();
            var greet = h < 6 ? '凌晨好' : h < 12 ? '早上好' : h < 18 ? '下午好' : '晚上好';
            var timeStr = greet + '，现在时间：' + now.getFullYear() + '-' + (now.getMonth()+1) + '-' + now.getDate() + ' ' + now.getHours() + ':' + (now.getMinutes()<10?'0':'') + now.getMinutes();
            $('#welcomeTime').text(timeStr);
        }
        updateTime();
        setInterval(updateTime, 60000);

        
    });

  
</script>
</body>
</html>